<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller {
   	public function index(){
        $this->load->view('login', $data);
	}
	public function signin(){
		$this->load->helper('url');
		$this->load->model('admin_model','admin');
		$admin=$this->input->post('admin');
		$where=array("user_name = '".$admin['user_name']."'","user_password = '".$admin['user_password']."'");
		$data=$this->admin->where($where)
					  ->select_all("admin.id,admin.user_name,admin.user_realname,admin.user_role",null,null,true,1,null);
	
		if($data['total_num']==1){
			$this->session->set_userdata($data['list'][0]);
			redirect(base_url('admin/index/index'));

		}else{
			redirect(base_url('login'));
		}
		die();
	}
	
	 public function login_out()
    {
      $this->session->sess_destroy();
      redirect(base_url('login'));
	}
}